package modules

import (
	"github.com/fogleman/gg"
)

type Words struct {
	PositionX  float64 `json:"positionX"`
	PositionY  float64 `json:"positionY"`
	Text       string  `json:"text"`
	TextWidth  float64 `json:"textWidth"`
	LineHeight float64 `json:"lineHeight"`
	FontSize   float64 `json:"fontSize"`
	FontColor  string  `json:"fontColor"`
	TextAlign  string  `json:"textAlign"`
}

// 插入文字
func drawWords(poster *Poster, canvas *gg.Context) {
	for _, word := range poster.Words {
		canvas.LoadFontFace("./resources/fonts/msyh.ttf", word.FontSize)
		canvas.SetHexColor(word.FontColor)
		canvas.DrawStringWrapped(word.Text, word.PositionX, word.PositionY, 0, 0, word.TextWidth, word.LineHeight, gg.AlignLeft)
	}
}
